package com.dongdong.controller;

import com.dongdong.data.DataResult;
import com.dongdong.data.ResponseStatusEnum;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/19 16:54
 * @Version 1.0
 **/
@Controller
@RequestMapping("tbUserController")
public class TbUserController {

    private static final Logger logger = LoggerFactory.getLogger(TbUserController.class);

    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("sendCode")
    @ResponseBody
    public DataResult sendCode(String phone){
        try {
            rocketMQTemplate.convertAndSend("sms_code",phone);
            return DataResult.response(ResponseStatusEnum.SUCCESS);
        }catch (Exception e){
            logger.error("发送错误");
            return DataResult.response(ResponseStatusEnum.INTERNAL_SERVER_ERROR);
        }
    }

}

